﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.Discovery;
using System.Xml;
using System.Xml.Linq;
using System.Threading;
using System.ComponentModel;

namespace TestClient
{
	class Program
	{
		static void Main(string[] args)
		{

			IPMulticastLib.IPMulticaster mCaster = new IPMulticastLib.IPMulticaster("234.5.5.1", 5555, 4, true);
			mCaster.MessageReceived += new IPMulticastLib.MessageReceivedEventHandler(mCaster_MessageReceived);
			

			string cmdMsg = "";

			while (true)
			{
				Console.WriteLine("Enter A Command Message:");
				
				cmdMsg = Console.ReadLine();

				switch (cmdMsg)
				{
					//case "GET":
					//    Console.WriteLine("Getting Messages...");
					//    mCaster.GetMessages().ForEach(delegate(string msg)
					//        {
					//            Console.WriteLine(msg);
					//        });
					//	break;
					case "EXIT":
						Console.WriteLine("Exiting...");
						break;
					default:
						mCaster.Send(cmdMsg);
						break;
				}
				Console.WriteLine();
				Console.WriteLine();
			}
		}

		static void mCaster_MessageReceived(object sender, IPMulticastLib.MessageReceivedEventArgs e)
		{
			Console.WriteLine("MSG Received: {0} @ {1}", e.Message, e.Timestamp);
		}
	
	}
}